home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Arrays of strings (linking)
- Date: Fri, 29 Mar 96 13:11:59 GMT
- Organization: none
- Message-ID: <828105119snz@genesis.demon.co.uk>
- References: <4jbkpg$5m7@news.ariadne-t.gr> <3159F9EC.1835@willows.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <3159F9EC.1835@willows.com>
- tarang@willows.com "Tarang Deshpande" writes:
-
- >char* strjoin ( char *str1, char* str2 )
-
- strjoin is a reserved identifier - you should call the function something
- else (i.e. something that doesn't start with str followed by a lowercase
- letter) e.g. str_join or Strjoin or strJoin are all OK.
-
- >{
- >
- > char *str = malloc ( strlen ( str1 ) + strlen ( str2 ) + 1 );
- >
- > if ( str )
- > {
- > *str = '\0';
- > strcat ( str, str1 );
-
- Or just use strcpy().
-
- > strcat ( str, str2 );
-
- Or replace all 3 lines with:
-
- sprintf(str, "%s%s", str1, str2);
- > }
- >
- > return ( str );
- >
- >}
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-